<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <title>医疗云·查看问卷数据</title>
    <script src="/jslib/jquery-3.4.1.min.js"></script>
    <script src="/jslib/grhtml5-6.7-min.js"></script>
    <script src="/jslib/grwebapp.js"></script>
    <script src="/jslib/lobster.js"></script>
    <style>
        body,
        html {
            height: 100%;
            width: 100%;
            margin: 0;
            background: #fff;
        }
    </style>
</head>

<body>
    <div class="layui-btn-group"
        style="height: 5%; padding-top: 5px; padding-left: 10px;padding-right: 20px; font-size: 20px;">
        <div style="float: left;  position: relative;">
            <a class="layui-btn layui-btn-primary" href='javascript:webapp({});'>预览</a>
            <a class="layui-btn layui-btn-primary" href='javascript:webapp({"type":"print"});'>打印</a>
            <a class="layui-btn layui-btn-primary" href='javascript:webapp({"type":"pdf"});'>导出PDF</a>
            <a class="layui-btn layui-btn-primary" href='javascript:webapp({"type":"xls"});'>导出Excel</a>
        </div>
        <div style="float: right;  position: relative;">
            <input type="checkbox" class="checkbox" name="CreateTime" />填写时间
            <input type="checkbox" class="checkbox" name="UpdateTime" />更新时间
            <input type="checkbox" class="checkbox" name="WriteTimeLong" />填写时长(秒)
            <input type="checkbox" class="checkbox" name="WriteDevice" />操作设备
            <input type="checkbox" class="checkbox" name="WriteOS" />操作系统
            <input type="checkbox" class="checkbox" name="WriteBrower" />浏览器
            <input type="checkbox" class="checkbox" name="WriteLocation" />填写地区
            <input type="checkbox" class="checkbox" name="WriteIP" />IP地址
        </div>
    </div>
    <div id="report_holder" style="width: 98%; height: 92%; overflow: auto; padding: 10px;"></div>
</body>

</html>


<script type="text/javascript">
    var reportViewer;


    (function () {

        lobstercommon.name="lobsterlayui";

        String.prototype.myReplace = function (f, e) {//吧f替换成e
            var reg = new RegExp(f, "g"); //创建正则RegExp对象   
            return this.replace(reg, e);
        }

        var formid = lobstercommon.GetUrlParam("formid");
        //rubylong.grhtml5.barcodeURL = "Barcode.ashx";

        if (formid != "false") {
            try{
            webapp_urlprotocol_startup(); //启动WEB报表客户端程序，以便侦听接受 WebSocket 数据。这句特别重要*：只有在WEB报表客户端程序后，才能进行WebSocket通讯
            }catch{}
            
            var _reportURL =lobstercommon.GetLowCodeUrl('report.getreportfile')+'&appid='+lobstercommon.GetAppId()+'&ssotoken='+lobstercommon.GetSSOToken()+'&formid='+formid;
            var _dataURL = lobstercommon.GetLowCodeUrl('report.getformdata')+'&appid='+lobstercommon.GetAppId()+'&ssotoken='+lobstercommon.GetSSOToken()+'&formid='+formid;

            runReport(_reportURL, _dataURL);

            //document.title += reportViewer.run_args.reportid;

            //监听url的变化
            $(window).bind('hashchange', function () {
                var newreportURL = _reportURL + window.location.hash.toString().myReplace("#", "&");
                runReport(newreportURL, _dataURL);
            });

            $('.checkbox').click(function () {
                var urlparam = '';
                $.each($('.checkbox:checked'), function () {
                    console.log("你选了：" + $(this).attr('name'));
                    urlparam += '#' + $(this).attr('name') + '=true';
                });
                window.location.hash = urlparam;
            });
        }
    })();

    //rubylong.grhtml5.barcodeURL = "Barcode.ashx";

    //客户端预览报表
    function webapp(args) {
        args.baseurl = "";// window.rootURL;
        args.report = reportViewer.reportURL;//
        args.data = reportViewer.dataURL;//
        if (!reportViewer.dataURL) {
            args.selfsql = true;
        }

        webapp_ws_run(args);
    }

    //报表显示
    function runReport(_reportURL, _dataURL) {
        reportViewer = window.rubylong.grhtml5.insertReportViewer("report_holder", _reportURL, _dataURL);
        reportViewer.start(); //启动报表运行，生成报表
    }
</script>